package com.yanqu.road.entity.buildDaoUtil;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.log.vehiclesoul.*;


import java.lang.reflect.Field;

/**
 * 把Log类转换成php的数组 只用于生成的sql或者autoLog
 */
public class LogClassToPhp {
    public static void main(String[] args) {
        Class<LogVehicleSoulWash> clz = LogVehicleSoulWash.class;
        String tableName = "";
        Field[] fields = clz.getDeclaredFields();
        String output = "";
        if (clz.isAnnotationPresent(FieldTypeAnnotation.class)) {
            tableName = "\"" + clz.getAnnotation(FieldTypeAnnotation.class).tableName() + "\"";
            output = tableName + " => [" + "\r\n";
            for (Field field : fields) {
                if (field.isAnnotationPresent(FieldTypeAnnotation.class)) {
                    FieldTypeAnnotation fieldTypeAnnotation = field.getAnnotation(FieldTypeAnnotation.class);
                    String fieldName = "'" + field.getName() + "'";
                    String fieldDesc = "'" + fieldTypeAnnotation.desc() + "'";
                    String lineString = fieldName + " => " + fieldDesc + ",";
                    output += "         "+lineString + "\r\n";
                }
            }
            output += "],";
        }

        System.out.println(output);
    }


}
